{include file="public_head" /}

<!-- Select2 -->
<link href="__STATIC__/css/select/select2.min.css" rel="stylesheet">

<body class="nav-md">

<div class="container body">

    <div class="main_container">

        {include file="public_sidebar,public_nav" /}
        <!-- page content -->
        <div class="right_col" role="main">
            <div class="">

                <div class="page-title">
                    <div class="title_left">
                        <h3>订单详细管理</h3>
                    </div>
                </div>
                <div class="clearfix"></div>
                <div class="row">
                    <div class="col-md-12 col-sm-12 col-xs-12">
                        <div class="x_panel">
                            <div class="x_title">
                                <h2>查看订单
                                    <!--<small>different form elements</small>-->
                                </h2>
                                <ul class="nav navbar-right panel_toolbox">
                                    <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                                    </li>
                                    <li><a class="close-link"><i class="fa fa-close"></i></a>
                                    </li>
                                </ul>
                                <div class="clearfix"></div>
                            </div>
                            <div class="x_content">
                                <div class="printArea">
                                <br/>
                                <form class="form-horizontal form-label-left" enctype="multipart/form-data" action=""
                                      method="post" id="registerForm">

                                    <div class="form-group dc">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">订 单 号：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            <div>{$item.shop_order_number}&nbsp;&nbsp;&nbsp;&nbsp;</div>
                                        </div>
                                    </div>
                                    <div class="form-group dc">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">买家账号：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            <div>{$item.username} {:input('car_number')}</div>
                                        </div>
                                    </div>
                                    <div class="form-group dc">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">是否认证：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            <div>{:input('is_certification_text')}</div>
                                        </div>
                                    </div>

                                    <div class="form-group dc">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">绩效订单：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            <div>
                                                {switch name="item.finance_order"}
                                                {case 1}业务员订单{/case}
                                                {case 2}二维码订单{/case}
                                                {case 3}门店订单{/case}
                                                {case 4}普通订单{/case}
                                                {default /}-
                                                {/switch}
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group dc">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">(线上/下)订单：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            <div>
                                                {switch name="item.order_online"}
                                                {case 1}线上订单{/case}
                                                {case 2}线下订单{/case}
                                                {default /}-
                                                {/switch}
                                            </div>
                                        </div>
                                    </div>

                                    <div class="form-group dc">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">下单/退款时间：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            <div>{$item.create_time}{in name="$item.status" value="10,11,12"} / {$item.refund_create_time}{/in}</div>
                                        </div>
                                    </div>
                                    <div class="form-group dc">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">运费：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            <div>{$item.freight}&nbsp;&nbsp;&nbsp;&nbsp;</div>
                                        </div>
                                    </div>
                                    <div class="form-group dc">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">总金额：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            <div>{$item.amount}&nbsp;&nbsp;&nbsp;&nbsp;</div>
                                        </div>
                                    </div>
                                    {in name="$item.status" value="10,11,12"}
                                    <div class="form-group dc">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">退款金额：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            <div>{$refund.amount}-{switch name="$item.refund.type"}
                                                {case 1}退款{/case}
                                                {case 2}退货{/case}{/switch}</div>
                                        </div>
                                    </div>
                                    <div class="form-group dc">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">退款理由：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            <div>{$refund.title}&nbsp;&nbsp;&nbsp;&nbsp;</div>
                                        </div>
                                    </div>
                                    <div class="form-group dc">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">退款说明：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            <div>{$refund.explain}&nbsp;&nbsp;&nbsp;&nbsp;</div>
                                        </div>
                                    </div>
                                    {/in}
                                    <div class="form-group dc">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">买家留言：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            <div>{$item.explain}&nbsp;&nbsp;&nbsp;&nbsp;</div>
                                        </div>
                                    </div>
                                    <div class="form-group dc">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">支付方式：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            <div>{switch name="item.pay_way"}{case 1}线上{/case}{case 2}线下{/case}{/switch}&nbsp;&nbsp;&nbsp;&nbsp;</div>
                                        </div>
                                    </div>
                                    <div class="form-group dc">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">配送方式：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            <div>{switch name="item.shipping"}{case 1}商家配送{/case}{case 2}到店自提{/case}{/switch}&nbsp;&nbsp;&nbsp;&nbsp;</div>
                                        </div>
                                    </div>
                                    <div class="form-group dc">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">支付类型：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            <div>{switch name="item.pay_type"}{case 1}微信{/case}{case 2}支付宝{/case}{default /}-{/switch}&nbsp;&nbsp;&nbsp;&nbsp;</div>
                                        </div>
                                    </div>
                                    <div class="form-group dc">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">收货地址详情：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            姓　　名：{$item.address_name}<br>
                                            手 机 号 ：{$item.address_phone}<br>
                                            地　　区：{$item.area_info}<br>
                                            详细地址：{$item.address}<br>
                                        </div>
                                    </div>
                                    <div class="form-group dc">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">订单状态：</label>
                                        <div class="col-md-1 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            {switch name="item.status"}
                                            {case 1}未支付{/case}
                                            {case 2}已支付{/case}
                                            {case 3}已发货{/case}
                                            {case 4}已完成{/case}
                                            {case 5}待评价{/case}
                                            {case 10}退款中{/case}
                                            {case 11}退款成功{/case}
                                            {case 12}退款失败{/case}
                                            {case 20}已取消({$item.cancel_content}){/case}
                                            {/switch}
                                            <br/>
                                            {if condition="$item.status eq 2"}
                                            <input type="checkbox" name="status"  value="3" datatype="*" nullmsg="请选择已发货！" > 已发货
                                            {/if}

                                        </div>

                                    </div>


                                    <div class="divider-dashed"></div>

                                    <div class="form-group dc">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">包含商品：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            <table width="80%" border="1" style="font-family: '微软雅黑';">
                                                <tr align="center" style="font-size: 16px;">
                                                    <td>商品ID</td>
                                                    <td>商品图片</td>
                                                    <td>商品名称</td>
                                                    <td>商品规格</td>
                                                    <td>商品价格</td>
                                                    <td>购买数量</td>
                                                </tr>
                                                {volist name='item.goods_list' id='goods_list'}
                                                <tr align="center">
                                                    <td>{$goods_list.goods_id|default=''}</td>
                                                    <td style="padding: 20px;"><img id="imgShow" src="__PUBLIC__/{$goods_list.thumb_img|default=''}"
                                                                                    width="100" height="100"
                                                                                    onerror="this.src='__STATIC__/images/default.png'"/></td>
                                                    <td>{$goods_list.title|default=''}</td>
                                                    <td>{$goods_list.attribute|default='无'}</td>
                                                    <td>{$goods_list.price|default=''}</td>
                                                    <td>{$goods_list.number|default=''}</td>
                                                </tr>
                                                {/volist}
                                            </table>
                                        </div>
                                    </div>
                                    <div class="form-group dc">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">是否开发票：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            {switch name="item.bill"}{case 1}开{/case}{case 2} 否{/case}{default /}{/switch}<br>
                                            {eq name="$item.bill" value="1"}
                                            发票类型：{switch name="item.bill_type"}{case 1}电子{/case}{case 2} 普通{/case}{case 3} 增值税{/case}{default /}{/switch}<br>
                                            发票抬头：{switch name="item.bill_header"}{case 1}个人{/case}{case 2} 单位{/case}{default /}{/switch}<br>
                                            发票内容：{$item.bill_content}<br>
                                            发票电话：{$item.bill_phone}<br>
                                            电子邮箱：{$item.bill_email}<br>

                                            {/eq}
                                        </div>
                                    </div>
                                    {in name="item.status" value="3"}
                                    <div class="form-group dc">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">备注信息：</label>
                                        <div class="col-md-1 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                                <textarea type="text" placeholder="备注" style="width: 500px;height: 100px;"
                                                          class="form-control col-md-7 col-xs-12" name="explain">{$item.explain|default=''}</textarea>

                                        </div>
                                    </div>
                                    {/in}
                                    {if condition="strpos('11,10,12',(string)$item.status) !== false"}
                                    <div class="form-group dc">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">退款审核记录：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            <table width="80%" border="1" style="font-family: '微软雅黑';">
                                                <tr align="center" style="font-size: 16px;">
                                                    <td>申请者</td>
                                                    <td>申请门店</td>
                                                    <td>审核状态</td>
                                                    <td>审核时间</td>
                                                    <td>失败原因</td>
                                                </tr>
                                                {volist name='refund_order_audit_records' id='goods_list'}
                                                <tr align="center">
                                                    <td>{$goods_list.username|default=''}</td>
                                                    <td>{$goods_list.shop_title|default=''}</td>
                                                    <td>
                                                        {switch name="$goods_list.status"}
                                                        {case 11}审核成功{/case}
                                                        {case 12}审核失败{/case}
                                                        {/switch}
                                                    </td>
                                                    <td>{$goods_list.create_time|default=''}</td>
                                                    <td>{$goods_list.fail_explain|default=''}</td>
                                                </tr>
                                                {/volist}
                                            </table>
                                        </div>
                                    </div>
                                    {/if}

                                    {in name="item.status" value="10"}
                                    {if condition="$refund_button eq true"}
                                    <div class="form-group dc">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">退款状态：</label>
                                        <div class="col-md-1 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            <select name="status" class="form-control" style="width: 200px;float: left;" tabindex="-1" {in name='item.status' value='11,12'}disabled{/in}>
                                            <option value="11" {eq name='item.status' value='11'}selected{/eq}>申请退款成功</option>
                                            <option value="12" {eq name='item.status' value='12'}selected{/eq}>申请退款失败</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="form-group dc">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">未退款理由：</label>
                                        <div class="col-md-1 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                                <textarea type="text" placeholder="未退款理由,不填写留空" style="width: 500px;height: 100px;"
                                                          class="form-control col-md-7 col-xs-12" name="fail_explain">{$refund_find.message|default=''}</textarea>
                                            <div style="width:500px;clear: both">
                                                <span style="font-size: 16px;color: red">注：只有在退款状态是退款失败的时候填写</span>
                                            </div>
                                        </div>
                                    </div>
                                    {/if}
                                    {/in}
                                    {if condition="strpos('2,3,4,5',(string)$item.status) !== false"}
                                    <div class="form-group service_people">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">服务人员与提成：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            <table width="100%" border="1" style="font-family: '微软雅黑';">
                                                <tr align="center" style="font-size: 16px;">
                                                    <td width="160">服务门店</td>
                                                    <td width="70">服务人员</td>
                                                    <td width="">服务分类</td>
                                                    <td width="70">提成金额</td>

                                                    <td width="150">消费日期</td>
                                                    <td width="150">服务内容</td>
                                                    {eq name=":session('auding_status')" value="2"}
                                                    <td>操作</td>
                                                    {/eq}
                                                </tr>
                                                {volist name='gift_assignor_records' id='vo'}
                                                <tr align="center">
                                                    <td>{$vo.shop_title|default=''}</td>
                                                    <td>{$vo.name|default=''}</td>
                                                    <td>{$vo.title|default=''}</td>
                                                    <td>{$vo.assignor_price|default=''}</td>
                                                    <td>{$vo.create_time|default=''}</td>
                                                    <td>{$vo.title|default=''}</td>
                                                    {eq name=":session('auding_status')" value="2"}
                                                    <td onclick="del({$vo.id})">删除</td>
                                                    {/eq}
                                                </tr>
                                                {/volist}
                                            </table>
                                        </div>
                                    </div>

                                    <div class="form-group service_people dc" >
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">服务人员提成：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <table class="table table-striped table-bordered table-hover">
                                                <thead>
                                                <th>服务人员</th>
                                                <th>服务内容</th>
                                                <th>提成金额</th>
                                                <th>操作</th>
                                                </thead>
                                                <tbody id="fieldtr">
                                                <tbody align="right">
                                                <tr>
                                                    <td colspan="4"><a href="javascript:;" class="addNewTr" title="新增一条">新增一条</a></td>
                                                </tr>
                                                </tbody>

                                            </table>
                                        </div>
                                    </div>
                                    {/if}

                                </div>

                                <div class="form-group ">
                                    <label class="control-label col-md-3 col-sm-3 col-xs-12" style="text-align: right">是否隐藏会员提成：</label>
                                    <div class="col-md-6 col-sm-6 col-xs-12">
                                        <label class="radio_box">
                                            <input type="radio" name="type" id="status_1" class="cartradio"
                                                   value="1"
                                                   datatype="*"
                                                   nullmsg="请选择会员卡类型！" errormsg="请选择会员卡类型！"
                                                   {eq name='item.type|default="1"' value='1' }
                                                   checked
                                                   {/eq}
                                            >&nbsp;&nbsp;
                                            <label for="status_1"></label>
                                            <span>否</span>
                                            &nbsp;&nbsp;
                                        </label>
                                        <label class="radio_box">
                                            <input type="radio" name="type" id="status_2" class="cartradio"
                                                   value="2"
                                                   datatype="*"
                                                   nullmsg="请选择会员卡类型！" errormsg="请选择会员卡类型！"
                                                   {eq name='item.type|default=""' value='2' }
                                                   checked
                                                   {/eq}
                                            >&nbsp;&nbsp;
                                            <label for="status_2"></label>
                                            <span>是</span>
                                            &nbsp;&nbsp;
                                        </label>
                                    </div>
                                </div>
                                <div style="clear: both"></div>
                                <div class="form-group">
                                    <label class="control-label col-md-3 col-sm-3 col-xs-12" style="text-align: right">只保留提成：</label>
                                    <div class="col-md-6 col-sm-6 col-xs-12">
                                        <label class="radio_box">
                                            <input type="radio" name="type2" id="status_3" class="cartradio"
                                                   value="1"
                                                   datatype="*"
                                                   nullmsg="请选择会员卡类型！" errormsg="请选择会员卡类型！"
                                                   {eq name='item.type|default="1"' value='1' }
                                                   checked
                                                   {/eq}
                                            >&nbsp;&nbsp;
                                            <label for="status_3"></label>
                                            <span>否</span>
                                            &nbsp;&nbsp;
                                        </label>
                                        <label class="radio_box">
                                            <input type="radio" name="type2" id="status_4" class="cartradio"
                                                   value="2"
                                                   datatype="*"
                                                   nullmsg="请选择会员卡类型！" errormsg="请选择会员卡类型！"
                                                   {eq name='item.type|default=""' value='2' }
                                                   checked
                                                   {/eq}
                                            >&nbsp;&nbsp;
                                            <label for="status_4"></label>
                                            <span>是</span>
                                            &nbsp;&nbsp;
                                        </label>
                                    </div>
                                </div>


                                    <div class="form-group">
                                        <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
                                            <!--{in name="$item.status" value="2"}-->
                                            <!--<button type="submit" class="btn btn-primary">提交</button>-->
                                            <!--{/in}-->
                                            {if condition="$item.status eq 10 && $refund_button == true && strpos('5,7,8,9,10',(string)session('role_id')) !== false"}
                                            <button type="submit" class="btn btn-primary">退款申请</button>
                                            {/if}
                                            <button type="button"  class="btn btn-danger" id="btnPrint">打印文本区域</button>
                                            <a type="reset" class="btn btn-success" onclick="history.go(-1)">返回</a>
                                            {in name="$item.status" value="50,1"}
                                            <a onclick="cancel({$item.member_id},{$item.id})" class="btn btn-primary">取消订单</a>
                                            {/in}
                                            {if condition="strpos('2,3,4,5',(string)$item.status) !== false"}
                                            <button type="submit" class="btn btn-primary">提交订单</button>
                                            {/if}
                                        </div>
                                    </div>
                                </form>
                                <div class="row">

                                    <div class="x_content col-md-12 col-sm-12 col-xs-12">
                                        <div class="form-group">
                                            <label class="control-label col-md-3 col-sm-3 col-xs-12"
                                                   style="text-align: right">会员付款码：</label>
                                            <div class="col-md-3 col-sm-6 col-xs-12">
                                                <input type="text" placeholder="线下扫码机获得" onchange="" {neq
                                                       name="$item.status" value="1" }disabled{/neq}
                                                class="form-control col-md-7 col-xs-12" name="auth_code"
                                                value="{$item.auth_code|default=''}" datatype="*" nullmsg="请填写运费金额"
                                                >
                                            </div>
                                            {eq name="$item.status" value="1"}
                                            <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
                                                <a type="reset" class="btn btn-success" onclick="mic_w_pay()">微信支付</a>
                                                <a type="reset" class="btn btn-success" onclick="mic_a_pay()">支付宝支付</a>
                                                <input type="hidden" name="order_amount" value="{$item.amount}"/>
                                                <input type="hidden" name="order_number" value="{$item.shop_order_number}"/>

                                            </div>
                                            {/eq}
                                        </div>
                                    </div>
                                </div>


                            </div>
                        </div>
                    </div>
                </div>


            </div>
            <!-- /page content -->

        </div>

    </div>
</div>

{include file="public_foot" /}
<!-- validform -->
<script src="__STATIC__/js/Validform_v5.3.2_min.js"></script>
<script src="__STATIC__/js/layer.js"></script>
<!--select-->
<script src="__STATIC__/js/select/select2.full.min.js"></script>
<script>
    function mic_w_pay() {
        var auth_code = $("[name='auth_code']").val();
        var out_trade_no = $("[name='order_number']").val();
        var price = $("[name='order_amount']").val();

        if(!auth_code){
            layer.msg('付款码不能为空');
            return;
        }

        $.ajax({
            type: "POST",
            url: "{:url('mic/w_pay')}",
            data: {auth_code:auth_code, out_trade_no:out_trade_no,price:price},
            dataType: "json",
            success: function(ret){
                if(ret == true){
                    layer.msg('支付成功');
                    history.go(0);
                }
                else{
                    layer.msg('支付失败');
                }
            }

        });
    }

    function mic_a_pay() {

        var auth_code = $("[name='auth_code']").val();
        var out_trade_no = $("[name='order_number']").val();
        var price = $("[name='order_amount']").val();

        if(!auth_code){
            layer.msg('付款码不能为空');
            return;
        }

        $.ajax({
            type: "POST",
            url: "{:url('mic/a_pay')}",
            data: {auth_code:auth_code, out_trade_no:out_trade_no,price:price},
            dataType: "json",
            success: function(ret){
                if(ret == true){
                    layer.msg('支付成功');
                    history.go(0);
                }
                else{
                    layer.msg('支付失败');
                }
            }

        });
    }

    function mic_a_pay() {

        var auth_code = $("[name='auth_code']").val();
        var out_trade_no = $("[name='order_number']").val();
        var price = $("[name='order_amount']").val();

        if(!auth_code){
            layer.msg('付款码不能为空');
            return;
        }

        $.ajax({
            type: "POST",
            url: "{:url('mic/a_pay')}",
            data: {auth_code:auth_code, out_trade_no:out_trade_no,price:price},
            dataType: "json",
            success: function(ret){
                if(ret == true){
                    layer.msg('支付成功');
                    history.go(0);
                }
                else{
                    layer.msg('支付失败');
                }
            }

        });
    }
    function cancel(member_id,order_id){
        $(function(){
//            var member_id = member_id;
            //var order_id = order_id;
            //$('#send').click(function(){

                $.ajax({

                    type: "POST",

                    url: "{:url('index/order/cancel')}",

                    data: {member_id:member_id, order_id:order_id},

                    dataType: "json",

                    success: function(data){

                        //  $('#resText').empty();   //清空resText里面的所有内容
                        //var obj = JSON.parse(data);
                        if(data.code == 200){
                            layer.msg('订单取消成功');
                            history.go(0);
                            window.location.href = "{:url('index')}"
                        }
                        else{
                            layer.msg('取消失败');
                        }
                        //var html = '';

//                        $.each(data, function(commentIndex, comment){
//
//                            html += '<div class="comment"><h6>' + comment['username']
//
//                                + ':</h6><p class="para"' + comment['content']
//
//                                + '</p></div>';
//
//                        });
//
//                        $('#resText').html(html);

                    }

                });

           /// });

        });
    }
</script>
<script>
    function delThisTr(trobj)
    {
        trobj.parent().parent().remove();
    }
    function del(id) {


        $.ajax({
            type: "POST",
            url: "{:url('console/gift_order/delete')}",
            data: {id:id},
            dataType: "json",
            success: function(data){
                //  $('#resText').empty();   //清空resText里面的所有内容
                //var obj = JSON.parse(data);
                if(data.code == 200){
                    layer.msg('删除成功');
                    history.go(0);
                    //window.location.href = "{:url('index')}"
                }
                else{
                    layer.msg('取消失败');
                }

            }
        });
    }
    // validform
    $(function () {

        $.Tipmsg.r = null;

        var showmsg = function (msg) {
            //假定你的店铺商品提示方法为showmsg， 在方法里可以接收参数msg，当然也可以接收到o及cssctl;
            alert(msg);
        }

        // select2
        $(".select2_single").select2({
            placeholder: "请选择快递公司",
            allowClear: true
        });

        $(".select2_single2").select2({
            placeholder: "请选择订单状态",
            allowClear: true
        });

        $("#registerForm").Validform({
            tiptype: function (msg) {
                layer.msg(msg);
            },
            tipSweep: true
        });



        function delThis(trobj,id)
        {
            if(confirm('确认删除？')){
                $.ajax({
                    url : '{:url("service_order/shop_assignor_records")}',
                    data:{'id':id},
                    dataType:'html',
                    success:function(data){
                        data = JSON.parse(data);
                        console.log(data)
                        if(data.code == 200){
                            layer.msg('删除成功');
                            trobj.parent().parent().remove();
                        }else{
                            layer.msg(data.message);
                        }
                    }
                });
            }
        }
        var assgioner = {$shop_assignor};
        console.log(assgioner);
        var s = [];

        s = '<tr><td><select name="status" class="form-control" tabindex="-1">' + ss
        s += '</select></td>';
        console.log(s);
        var ss = [];
        $.each(assgioner, function(k,v){
            ss += '<option value="'+v.id+'">'+v.name+'</option>';
        });
        var gift_c;
        $.each({$order_goods}, function(k,v){ //服务人员提成
            gift_c += '<option value="'+v.id+'">'+v.three_level_name+'</option>';
        });
        var category = {$category};
        var cat_list;
        var repeat = '-';
        $.each(category, function(k,v){
            var dis;
            var price = '';
            if(v.count == 1 || v.count==2){ //1 2级
                dis = 'disabled';
            }else{
                price = '-'+v.price;
            }

            cat_list += '<option value="'+v.id+'-'+v.price+'"'+dis+'>'+'&nbsp&nbsp'.repeat(v.count)+'|--'+v.title+price+'</option>';
        });
        var gift_shop_content;
        $.each({$service_people_price2}, function(k,v){ //服务人员提成
            gift_shop_content += '<option value="'+v.id+'">'+v.cat_name+'</option>';
        });
        $(".addNewTr").click(function(){
            str = '<tr><td><select name="assignor_id[]" class="form-control" tabindex="-1">' + ss +
                '</select></td>' +
                '<td><select name="single_id[]" onchange="single2(this.value,this)" class="form-control" tabindex="-1">' + gift_c +
                '<td><input name="assignor_price[]" readonly class="form-control" value="'+{$order_goods}[0]['person_price']+'" /></td>'+
                '<td><a href="javascript:;" onclick="delThisTr($(this))">删除</a></td></tr>';
            $("#fieldtr").append(str);
        });


//    $(".addNewTr").click(function(){
//        str =
//            '<tr><td><input type="text" name="assignor_id[]"  /></td>' +
//            '<td><input type="text" name="assignor_price[]"  /></td>' +
//            '<td><input type="text" name="assignor_content[]" /></td>' +
//            '<td><a href="javascript:;" onclick="delThisTr($(this))">删除</a></td></tr>';
//        $("#fieldtr").append(str);
//    });

        function delThisTrr(trobj)
        {
            trobj.parent().parent().remove();
        }

        function shop(id){
            $.ajax({
                url : '{:url("ajaxfenlei")}',
                data:{'shop_id':id},
                dataType:'json',
                success:function(data){
                    var str = '<td><input name="assignor_price[]" readonly class="form-control" value="'+data+'" /></td>';
                    $(t).next().html(str);
                }
            });
        }
    })
</script>
</body>
<script src="/jquery.PrintArea.js" type="text/JavaScript" language="javascript"></script>
<script>

    function single2(id,t) {
        $.ajax({
            url : '{:url("ajaxfenlei")}',
            data:{'id':id,'order_id':{:input('id')}},
            dataType:'json',
            success:function(data){
                console.log(data);
                //var str = '<td><input name="assignor_price[]" readonly class="form-control" value="'+data+'" /></td>';
                $(t).parent().next().find('input').val(data);
            }
        });
    }
    $('#status_2').click(function () {

        $('.service_people').hide();

    });
    $('#status_1').click(function () {

        $('.service_people').show();

    });
    $("#btnPrint").click(function(){
        $(".printArea").printArea();
    });
    $("#btnPrintFull").click(function(){
        $("body").printArea();
    });
    $('#status_4').click(function () { //是隐藏提成

        $('.dc').hide();
    });
    $('#status_3').click(function () {

        $('.dc').show();
    });

</script>

</html>
